<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BackUsers extends Model
{
    use HasFactory;

    protected $table = 'zfm_users';

    /**
     * @name wl
     * @function 用户注册及记录
     * @param $user
     * @return \Illuminate\Database\Eloquent\Builder|Model|object|null
     */
    public static function userFirst($username, $where)
    {
        return self::where($username, $where)->first();
    }

    /**
     * @name wl
     * @function 注册方法
     * @param $vaLiDate
     * @return BackUsers
     */
    public static function userAdd($vaLiDate)
    {
        $user = new self();
        $user->username = $vaLiDate['username'];
        $user->password = $vaLiDate['password'];
        $user->email = $vaLiDate['email'];
        $user->save();
        return $user;


//        return self::create($vaLiDate);
    }

    /**
     * @name wl
     * @function  登录方法
     * @param $data
     * @return BackUsers
     */
    public static function login($data)
    {
        $user = new self();
        $user->username = $data['username'];
        $user->password = $data['password'];
        $user->save();
        return $user;
    }
}
